* FILE LAST RUN ON 02/06/2024 USING STATA/SE 17.0

clear all
set maxvar 25000
set matsize 11000

cd ""
* Please change the directory according to your own set-up

/* TO RUN THIS FILE
1) Make sure the CCES_final.dta is in a CCES subfolder 
2) Make sure that the do file creating the main tables are in the folder Table
3) Please install programme estout in case at ssc install estout, replace
4) Please create a subfolder Results
*/

use .\CCES\CCES_final.dta, clear

* No white advantage, no racial problem, and resentment for all observations

* For each item (no white advantage, racial problems are rare, Blacks should progress without favors, Slavery and discrimination are no impediment to Black progresses), regressions are run with and without control. I restrict attention to years post-2014 for comparability with British data.


local fe_year
local fe_state


reg NoWhiteAdv WhiteMale if Year>=2014, robust
qui sum NoWhiteAdv if e(sample)
estadd local mean= `r(mean)'
est store discrimmodel1

reg NoWhiteAdv WhiteMale Own Married Divorced HigherEdu HighSchool Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate if Year>=2014, robust
qui sum NoWhiteAdv if e(sample)
estadd local mean= `r(mean)'
estadd local fe_year "$\checkmark$"
estadd local fe_state "$\checkmark$"
est store discrimmodel2


reg NoRacProb WhiteMale if Year>=2014, robust 
qui sum NoRacProb if e(sample)
estadd local mean= `r(mean)'
est store discrimmodel3
reg NoRacProb WhiteMale Own Married Divorced HigherEdu HighSchool Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate if Year>=2014, robust
qui sum NoRacProb if e(sample)
estadd local mean= `r(mean)'
estadd local fe_year "$\checkmark$"
estadd local fe_state "$\checkmark$"
est store discrimmodel4




reg RacialResent1 WhiteMale if Year>=2014, robust
qui sum RacialResent1 if e(sample)
estadd local mean= `r(mean)'
est store discrimmodel5

reg RacialResent1 WhiteMale Own Married Divorced HigherEdu HighSchool Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate if Year>=2014, robust
qui sum RacialResent1 if e(sample)
estadd local mean= `r(mean)'
estadd local fe_year "$\checkmark$"
estadd local fe_state "$\checkmark$"
est store discrimmodel6


reg RacialResent2 WhiteMale if Year>=2014, robust 
qui sum RacialResent2 if e(sample)
estadd local mean= `r(mean)'
est store discrimmodel7
reg RacialResent2 WhiteMale Own Married Divorced HigherEdu HighSchool Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate if Year>=2014, robust
qui sum RacialResent2 if e(sample)
estadd local mean= `r(mean)'
estadd local fe_year "$\checkmark$"
estadd local fe_state "$\checkmark$"
est store discrimmodel8

qui do .\Table\Table_CCES_NoProb 
* The following command exports the table for Online Appendix D (same for every regression below)

* The following command exports the full table for Online Appendix F (available in the file Angry White Males - Dataverse.pdf in the APSR dataverse for this article)
esttab  discrimmodel2 discrimmodel4 discrimmodel6 discrimmodel8 using "./Results/fulltable_CCES_noprob", tex replace se obslast collabels(, none) nomtitle /// 
	/// We export the estimates from column1 to column4 in the file ab_comparison (in a specific folder)
	/// in the form of a tex file (you can choose other format) displaying standard errors instead of t-stat, with observations last
	 star(* 0.10 ** 0.05 *** 0.01) wrap mlabel("No White Adv." "Rac. Probl. Rare" "Resentment 1" "Resentment 2") ///
	/// Add the stars and label the columns
	 nonumbers cells(b(star fmt(4)) se(fmt(4) par)) compress label keep(WhiteMale Own Married Divorced HigherEdu HighSchool Age income*  workstatus* )  gaps  ///
	 /// The most important commands here are that we ask for 3 decimals (fmt(3)) for coeff and st. errors, we also use label
	 stats(age fe_year fe_state N, fmt(a1 %9.0fc 0)  labels(`"Sample"' `"Year Fe"' `"State Fe"' `"N.obs"'))  legend
	 /// Here we have the stats shown after the coefficients as well as their associated label

		 
		 
*  BY EDUCATION
* For the items on (no) white advantages and (uncommon) racial problems, three regressions with controls are run: 
* The first for individuals who have not finished High School or not revealed their degrees
* The second for individuals who have finished High School and completed none of some university education
* The third for individuals who have at least a Bachelor degree


local fe_year
local educ 

reg NoWhiteAdv WhiteMale Own Married Divorced  Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate if HighSchool==0 & HigherEdu ==0 & Year>=2014, robust
qui sum NoWhiteAdv if e(sample)
estadd local mean= `r(mean)'
estadd local fe_year "$\checkmark$"
estadd local educ "No high school"
estadd local fe_state "$\checkmark$"

est store educ1


reg NoWhiteAdv WhiteMale Own Married Divorced Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate if HigherEdu == 0 & HighSchool == 1 & Year>=2014, robust
qui sum NoWhiteAdv if e(sample)
estadd local mean= `r(mean)'
estadd local fe_year "$\checkmark$"
estadd local educ "High School"
estadd local fe_state "$\checkmark$"

est store educ2

reg NoWhiteAdv WhiteMale Own Married Divorced Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate if HigherEdu == 1 & HighSchool == 0 & Year>=2014, robust
qui sum NoWhiteAdv if e(sample)
estadd local mean= `r(mean)'
estadd local fe_year "$\checkmark$"
estadd local educ "University"
estadd local fe_state "$\checkmark$"
est store educ3

reg NoRacProb WhiteMale Own Married Divorced Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate  if HigherEdu == 0 & HighSchool == 0 & Year>=2014, robust
qui sum NoRacProb if e(sample)
estadd local mean= `r(mean)'
estadd local fe_year "$\checkmark$"
estadd local educ "No qualif./answer"
estadd local fe_state "$\checkmark$"
est store educ4

reg NoRacProb WhiteMale Own Married Divorced Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate  if HigherEdu == 0 & HighSchool == 1 & Year>=2014, robust
qui sum NoRacProb if e(sample)
estadd local mean= `r(mean)'
estadd local fe_year "$\checkmark$"
estadd local educ "High School"
estadd local fe_state "$\checkmark$"
est store educ5

reg NoRacProb WhiteMale Own Married Divorced Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate  if HigherEdu == 1 & HighSchool == 0 & Year>=2014, robust
qui sum NoRacProb if e(sample)
estadd local mean= `r(mean)'
estadd local fe_year "$\checkmark$"
estadd local educ "University"
estadd local fe_state "$\checkmark$"
est store educ6



qui do .\Table\Table_CCES_NoProb_educ
* The following command exports the table for Online Appendix D (same for every regression below)

* The following command exports the full table for Online Appendix F (available in the file Angry White Males - Dataverse.pdf in the APSR dataverse for this article)
esttab  educ* using "./Results/fulltable_CCES_noprob_educ", tex replace se obslast collabels(, none) nomtitle /// 
	/// We export the estimates from column1 to column4 in the file ab_comparison (in a specific folder)
	/// in the form of a tex file (you can choose other format) displaying standard errors instead of t-stat, with observations last
	 star(* 0.10 ** 0.05 *** 0.01) wrap mlabel("No White Adv." "No White Adv." "No White Adv." "Rac. Probl. Rare" "Rac. Probl. Rare" "Rac. Probl. Rare" ) ///
	/// Add the stars and label the columns
	 nonumbers cells(b(star fmt(4)) se(fmt(4) par)) compress label keep(WhiteMale Own Married Divorced Age income*  workstatus*  )  gaps  ///
	 /// The most important commands here are that we ask for 3 decimals (fmt(3)) for coeff and st. errors, we also use label
	 stats(educ fe_year fe_state N, fmt(a1 %9.0fc 0)  labels(`"Sample"' `"Year Fe"' `"State Fe"' `"N.obs"'))  legend
	 /// Here we have the stats shown after the coefficients as well as their associated label


	 
* BY AGE GROUP
* For the items on (no) white advantages and (uncommon) racial problems, three regressions with controls are run: 
* The first for individuals below the age of 25
* The second for individuals between 26 and 64 years old
* The third for individuals over 65 years old


gen age25 = 0
replace age25 = 1 if Age <=25
gen age26_64 = 0
replace age26_64 = 1 if Age> 25 & Age<65
gen age65 = 0
replace age65 = 1 if Age >=65
* Gone too far by education
local age 


reg NoWhiteAdv WhiteMale Own Married Divorced  Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate   if age25==1 & Year>=2014, robust
estadd local fe_year "$\checkmark$"
estadd local age "Under 25"
qui sum NoWhiteAdv if e(sample)
estadd local mean= `r(mean)'
estadd local fe_state "$\checkmark$"
est store age1

reg NoWhiteAdv WhiteMale Own Married Divorced  Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate if age26_64==1 & Year>=2014, robust
estadd local fe_year "$\checkmark$"
estadd local age "26-64"
qui sum NoWhiteAdv if e(sample)
estadd local mean= `r(mean)'
estadd local fe_state "$\checkmark$"
est store age2

reg NoWhiteAdv WhiteMale Own Married Divorced  Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate if age65==1 & Year>=2014, robust
estadd local fe_year "$\checkmark$"
estadd local age "Over 65"
qui sum NoWhiteAdv if e(sample)
estadd local mean= `r(mean)'
estadd local fe_state "$\checkmark$"
est store age3

reg NoRacProb WhiteMale Own Married Divorced  Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate if age25==1 & Year>=2014, robust
estadd local fe_year "$\checkmark$"
estadd local age "Under 25"
qui sum NoRacProb if e(sample)
estadd local mean= `r(mean)'
estadd local fe_state "$\checkmark$"
est store age4

reg NoRacProb WhiteMale Own Married Divorced  Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate if age26_64==1 & Year>=2014, robust
estadd local fe_year "$\checkmark$"
estadd local age "26-64"
qui sum NoRacProb if e(sample)
estadd local mean= `r(mean)'
estadd local fe_state "$\checkmark$"
est store age5

reg NoRacProb WhiteMale Own Married Divorced  Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate if age65==1 & Year>=2014, robust
estadd local fe_year "$\checkmark$"
estadd local age "Over 65"
qui sum NoRacProb if e(sample)
estadd local mean= `r(mean)'
estadd local fe_state "$\checkmark$"
est store age6


qui do .\Table\Table_CCES_NoProb_age
* The following command exports the table for Online Appendix D (same for every regression below)

* The following command exports the full table for Online Appendix F (available in the file Angry White Males - Dataverse.pdf in the APSR dataverse for this article)
esttab  age* using "./Results/fulltable_CCES_noprob_age", tex replace se obslast collabels(, none) nomtitle /// 
	/// We export the estimates from column1 to column4 in the file ab_comparison (in a specific folder)
	/// in the form of a tex file (you can choose other format) displaying standard errors instead of t-stat, with observations last
	 star(* 0.10 ** 0.05 *** 0.01) wrap mlabel("No White Adv." "No White Adv." "No White Adv." "Rac. Probl. Rare" "Rac. Probl. Rare" "Rac. Probl. Rare" ) ///
	/// Add the stars and label the columns
	 nonumbers cells(b(star fmt(4)) se(fmt(4) par)) compress label keep(WhiteMale Own Married Divorced Age income*  workstatus*  )  gaps  ///
	 /// The most important commands here are that we ask for 3 decimals (fmt(3)) for coeff and st. errors, we also use label
	 stats(age fe_year fe_state N, fmt(a1 %9.0fc 0)  labels(`"Sample"' `"Year Fe"' `"State Fe"' `"N.obs"'))  legend
	 /// Here we have the stats shown after the coefficients as well as their associated label



	 
***************************** PROBIT MODELS *************************************

* Here I rerun the main models (without splitting samples by educations or ages), using Probit instead of OLS.


local fe_year
local fe_state


probit NoWhiteAdv WhiteMale if Year>=2014, robust
qui sum NoWhiteAdv if e(sample)
estadd local mean= `r(mean)'
est store discrimmodelprob1

probit NoWhiteAdv WhiteMale Own Married Divorced HigherEdu HighSchool Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate if Year>=2014, robust
qui sum NoWhiteAdv if e(sample)
estadd local mean= `r(mean)'
estadd local fe_year "$\checkmark$"
estadd local fe_state "$\checkmark$"
est store discrimmodelprob2


probit NoRacProb WhiteMale if Year>=2014, robust 
qui sum NoRacProb if e(sample)
estadd local mean= `r(mean)'
est store discrimmodelprob3
probit NoRacProb  WhiteMale Own Married Divorced HigherEdu HighSchool Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate if Year>=2014, robust
qui sum NoRacProb if e(sample)
estadd local mean= `r(mean)'
estadd local fe_year "$\checkmark$"
estadd local fe_state "$\checkmark$"
est store discrimmodelprob4




probit RacialResent1 WhiteMale if Year>=2014, robust
qui sum RacialResent1 if e(sample)
estadd local mean= `r(mean)'
est store discrimmodelprob5

probit RacialResent1 WhiteMale Own Married Divorced HigherEdu HighSchool Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate if Year>=2014, robust
qui sum RacialResent1 if e(sample)
estadd local mean= `r(mean)'
estadd local fe_year "$\checkmark$"
estadd local fe_state "$\checkmark$"
est store discrimmodelprob6


probit RacialResent2 WhiteMale if Year>=2014, robust 
qui sum RacialResent2 if e(sample)
estadd local mean= `r(mean)'
est store discrimmodelprob7
probit RacialResent2 WhiteMale Own Married Divorced HigherEdu HighSchool Age income1-income16 workstatus1-workstatus8 i.Year i.inputstate if Year>=2014, robust
qui sum RacialResent2 if e(sample)
estadd local mean= `r(mean)'
estadd local fe_year "$\checkmark$"
estadd local fe_state "$\checkmark$"
est store discrimmodelprob8

* The following command exports the full table for Online Appendix F (available in the file Angry White Males - Dataverse.pdf in the APSR dataverse for this article)
esttab  discrimmodelprob* using "./Results/fulltable_CCES_noprob_probit", tex replace se obslast collabels(, none) nomtitle /// 
	/// We export the estimates from column1 to column4 in the file ab_comparison (in a specific folder)
	/// in the form of a tex file (you can choose other format) displaying standard errors instead of t-stat, with observations last
	 star(* 0.10 ** 0.05 *** 0.01) wrap mlabel("No White Adv." "No White Adv." "Rac. Probl. Rare" "Rac. Probl. Rare" "Resentment 1" "Resentment 1" "Resentment 2"  "Resentment 2") ///
	/// Add the stars and label the columns
	 nonumbers cells(b(star fmt(4)) se(fmt(4) par)) compress label keep(WhiteMale Own Married Divorced HigherEdu HighSchool Age income*  workstatus* )  gaps  ///
	 /// The most important commands here are that we ask for 3 decimals (fmt(3)) for coeff and st. errors, we also use label
	 stats( fe_year fe_state N, fmt(a1 %9.0fc 0)  labels(`"Year Fe"' `"State Fe"' `"N.obs"'))  legend
	 /// Here we have the stats shown after the coefficients as well as their associated label
